package golf;

import java.sql.ResultSet;
import java.sql.SQLException;

import database.DAO;


public class Guild {
	int no;
	String name;
	int server_no;
	int point;
	int member_cnt;
	int grade_no;
	GuildGrade grade;
	
	public Guild(){}
	/*
	 * GUILDNO	NUMBER
		GUILDNM	VARCHAR2(30 BYTE)
		SVNO	NUMBER
		GUILDPOINT	NUMBER
		GUILDMEMNO	NUMBER
		GUILDGRADENO	NUMBER
	 */
	public Guild(ResultSet rs){
		try {
			setNo( rs.getInt("GUILDNO") );
			setName( rs.getString("GUILDNM") );
			setServer_no( rs.getInt("SVNO") );
			setPoint( rs.getInt("GUILDPOINT") );
			setMember_cnt( rs.getInt("GUILDMEMNO") );
			setGrade_no( rs.getInt("GUILDGRADENO") );
			//DAO에 서버번호로 서버 가져올 수 있게 하는 메서드 추가하기!
			//setServer( DAO.getInstance().getServer )
		} catch (SQLException e) {
			System.out.println("Guild()생성자에서 ResultSet 다루는 도중 에러 발생!");
			e.printStackTrace();
		}
		
		setGrade( DAO.getInstance().getGuildGrade( getGrade_no() ) );
	}
		
	public int getNo() {
		return no;
	}
	public void setNo(int no) {
		this.no = no;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getServer_no() {
		return server_no;
	}
	public void setServer_no(int server_no) {
		this.server_no = server_no;
	}
	public int getPoint() {
		return point;
	}
	public void setPoint(int point) {
		this.point = point;
	}
	public int getMember_cnt() {
		return member_cnt;
	}
	public void setMember_cnt(int member_cnt) {
		this.member_cnt = member_cnt;
	}
	public int getGrade_no() {
		return grade_no;
	}
	public void setGrade_no(int grade_no) {
		this.grade_no = grade_no;
	}
	public GuildGrade getGrade() {
		return grade;
	}
	public void setGrade(GuildGrade grade) {
		this.grade = grade;
	}





	public static class GuildMember{
		public static String MEMBER_MASTER="마스터";
		public static String MEMBER_VICEMASTER="부마스터";
		public static String MEMBER_REGULAR="정회원";
		public static String MEMBER_ASSOCIATE="준회원";
		public static String MEMBER_WAITING="참가대기자";
		
		int guild_no;
		int char_no;
		String job_name;
		String char_name;
		
		public GuildMember(){}
		public GuildMember(ResultSet rs){
			try {
				setGuild_no(rs.getInt("GUILDNO"));
				setChar_no(rs.getInt("CHARNO"));
				setJob_name(rs.getString("JOBNM"));
				setChar_name(rs.getString("CHARNM"));
			} catch (SQLException e) {
				System.out.println("GuildMember()생성자에서  ResultSet활용 도중 에러발생!");
				e.printStackTrace();
			}
		}
		public int getGuild_no() {
			return guild_no;
		}
		public void setGuild_no(int guild_no) {
			this.guild_no = guild_no;
		}
		public int getChar_no() {
			return char_no;
		}
		public void setChar_no(int char_no) {
			this.char_no = char_no;
		}
		public String getJob_name() {
			return job_name;
		}
		public void setJob_name(String job_name) {
			this.job_name = job_name;
		}
		public String getChar_name() {
			return char_name;
		}
		public void setChar_name(String char_name) {
			this.char_name = char_name;
		}
		
	}


	public static class GuildGrade{
		int no;
		String name;
		int limit_point;
		int limit_member_cnt;
		float benefit_exp;
		/*
		 * GUILDGRADENO	NUMBER
			GUILDGRADENM	VARCHAR2(20 BYTE)
			GUILDGRADELIMITPOINT	NUMBER
			GUILDGRADELIMITMEMNO	NUMBER
			GUILDGRADEBENEFITEXP	FLOAT
		 */
		public GuildGrade(){}
		public GuildGrade(ResultSet rs){
			try {
				setNo( rs.getInt("GUILDGRADENO") );
				setName( rs.getString("GUILDGRADENM") );
				setLimit_point( rs.getInt("GUILDGRADELIMITPOINT") );
				setLimit_member_cnt( rs.getInt("GUILDGRADELIMITMEMNO") );
				setBenefit_exp( rs.getFloat("GUILDGRADEBENEFITEXP") );
			} catch (SQLException e) {
				System.out.println("GuildGrade()생성자에서 에러가 발생!");
				e.printStackTrace();
			}
		}
		public int getNo() {
			return no;
		}
		public void setNo(int no) {
			this.no = no;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public int getLimit_point() {
			return limit_point;
		}
		public void setLimit_point(int limit_point) {
			this.limit_point = limit_point;
		}
		public int getLimit_member_cnt() {
			return limit_member_cnt;
		}
		public void setLimit_member_cnt(int limit_member_cnt) {
			this.limit_member_cnt = limit_member_cnt;
		}
		public float getBenefit_exp() {
			return benefit_exp;
		}
		public void setBenefit_exp(float benefit_exp) {
			this.benefit_exp = benefit_exp;
		}
		
	}
}
